package com.un.ebs.customer.service.impl;

import com.un.ebs.customer.domain.Activity;
import com.un.ebs.customer.mapper.ActivityMapper;
import com.un.ebs.customer.service.ActivityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.un.ebs.customer.dto.*;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liubo
 * @since 2019-11-01
 */
@Service
public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements ActivityService {

    @Override
    public void add(ActivityAddDto req) {
        Activity obj = new Activity();
        obj.setName(req.getName());
        obj.setDesc(req.getDesc());
        obj.setStartDate(req.getStartDate());
        obj.setEndDate(req.getEndDate());
        obj.setIsDelete(false);
        obj.insert();
    }

    @Override
    public void update(ActivityUpdateDto req) {
        Activity obj = getById(req.getId());
        obj.setName(req.getName());
        obj.setDesc(req.getDesc());
        obj.setStartDate(req.getStartDate());
        obj.setEndDate(req.getEndDate());
        obj.updateById();
    }

    @Override
    public Activity queryById(String id) {
        return getBaseMapper().selectById(id);
    }

    @Override
    public void delete(String id){
        getBaseMapper().deleteById(id);
    }

}